﻿using System.Threading.Tasks;
using SmartCity.Shared;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;

namespace ParkManagement
{
    /// <summary>
    /// 车辆管理类
    /// </summary>
    public class CarManager : DomainService
    {
        private readonly IRepository<Car, int> _carRepository;

        public CarManager(
            IRepository<Car, int> carRepository)
        {
            _carRepository = carRepository;
        }

        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="plateNo"></param>
        /// <param name="type"></param>
        public async Task<Car> CreateAsync(
            int userId,
            string plateNo,
            CarType? type)
        {
            return await _carRepository.InsertAsync(
                new Car(
                    userId,
                    plateNo,
                    type
                )
            );
        }
    }
}